package com.kly.user.db.dao.impl;
import com.fqgj.common.base.AbstractBaseMapper;
import com.fqgj.common.utils.DateUtil;
import com.google.common.collect.Maps;
import com.kly.user.db.dao.UserOnlineReportDao;
import com.kly.user.db.dbo.UserMessageReporDBO;
import com.kly.user.db.entity.UserOnlineReportEntity;
import org.springframework.stereotype.Repository;

import java.util.HashMap;

/**
* User: linqu
* Date: 2023-10-18
* Time: 10:15:41.042
*/

@Repository
public class UserOnlineReportDaoImpl extends AbstractBaseMapper<UserOnlineReportEntity> implements UserOnlineReportDao {

    @Override
    public UserMessageReporDBO getUserOnlineReportTotal(Integer date, String chatterUserCode) {
        final HashMap<String, Object> params = Maps.newHashMap();
        params.put("chatterUserCode", chatterUserCode);
        if (date != null) {
            params.put("startDate", DateUtil.getDate(date + " 00:00:00", "yyyyMMdd HH:mm:ss"));
            params.put("endDate", DateUtil.getDate(date + " 23:59:59", "yyyyMMdd HH:mm:ss"));
        } else {
            params.put("startDate", DateUtil.getTodayBeginTime());
            params.put("endDate", DateUtil.getTodayOverTime());
        }
        return this.getSqlSession().selectOne(this.getStatement("getUserOnlineReportTotal"), params);
    }

}